﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace System
{
    /// <summary>
    /// 表示标准时间
    /// </summary>
    /// <remarks>
    /// 用于统一整个应用程序的时间
    /// </remarks>
    /// <creator>marc</creator>
    public static class StandardTime
    {
        private static IStandardTimeProvider _provider;
        /// <inheritdoc cref="IStandardTimeProvider"/>
        public static IStandardTimeProvider Provider
        {
            get { return _provider; }
            set
            {
                Check.NotNull(value, "标准时间提供器<StandardTime.Provider>必须设置");

                _provider = value;
            }
        }

        /// <summary>
        /// 当前时间
        /// </summary>
        public static DateTime Now => Provider.Now;

        /// <inheritdoc cref="StandardTime"/>
        static StandardTime()
        {
            Provider = new DefaultStandardTimeProvider();
        }
    }
}
